﻿using System.Data;
using System.IO;
using System.Reflection;


namespace eRechnung.FinanzOnline
{
    class ErrorCodes
    {
        private DataSet myDs;
        private DataTable ErrorCodeTable;
        public ErrorCodes()
        {
            myDs = new DataSet();
            Assembly Asm = Assembly.GetExecutingAssembly();
            Stream St = Asm.GetManifestResourceStream("eRechnung.ErrorCodes.xml");
            StreamReader ResRd = new StreamReader(St);
            myDs.ReadXml(ResRd);
            ErrorCodeTable = myDs.Tables["Row"];
        }

        public string ErrorText(string code)
        {
            string selection = "ErrorID = " + code;
            DataRow[] rows = ErrorCodeTable.Select(selection);
            if (rows == null)
            {
                return (null);
            }
            return (rows[0]["Text"].ToString().Trim());


        }
    }
}
